package com.cj.bus.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan(basePackages={"com.cj.bus.mapper"})
public class MybatisPlusConfig {


    /**
     * 分页插件
     *
     * @return the pagination interceptor
     * @date 2018 -12-20 14:02:16
     * @method Pagination interceptor pagination interceptor.
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    /**
     * 开始逻辑删除
     * @return the sql injector
     * @date 2018 -12-27 10:41:36
     * @method Sql  injector sql injector.
     */
    @Bean
    public ISqlInjector sqlInjector(){
        return new LogicSqlInjector();
    }

    /**
     * 打印sql
     *
     * @return the performance interceptor
     * @date 2018 -12-20 14:02:16
     * @method Performance interceptor performance interceptor.
     */
//    @Bean
//    public PerformanceInterceptor performanceInterceptor() {
//        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
//        // 格式化sql语句
//        Properties properties = new Properties();
//        properties.setProperty("format", "true");
//        performanceInterceptor.setProperties(properties);
//
//        return performanceInterceptor;
//    }
}